<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
    <meta name="author" content="火星科技 http://mars3d.cn " />
    <meta name="apple-touch-fullscreen" content="yes" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="x5-fullscreen" content="true" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    <!-- 标题及搜索关键字 -->
    <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
    <meta
      name="description"
      content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型  gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包  地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
    />

    <link rel="shortcut icon" type="image/x-icon" href="http://mars3d.cn/favicon.ico" />
    <title>雷达跟踪椎体 动态效果 | Mars3D | 三维地图 | 火星科技 | 合肥火星科技有限公司</title>

    <!--第三方lib-->
    <script
      type="text/javascript"
      src="../lib/include-lib.js"
      libpath="../lib/"
      include="jquery,jquery.range,font-awesome,bootstrap,bootstrap-checkbox,layer,haoutil,turf,mars3d,mars3d-space"
    ></script>

    <link href="css/style.css" rel="stylesheet" />
  </head>

  <body class="dark">
    <!--加载前进行操作提示，优化用户体验-->
    <div id="mask" class="signmask" onclick="removeMask()"></div>

    <div id="mars3dContainer" class="mars3d-container"></div>

    <!-- 面板 -->
    <div class="infoview">
      <div style="width: 100%; text-align: center; font-size: 16px">参数设置</div>
      <table class="mars-table">
        <tr>
          <td class="nametd"></td>
          <td>
            <div class="checkbox checkbox-primary checkbox-inline">
              <input id="chkShow" class="styled" type="checkbox" checked />
              <label for="chkShow"> 显示/隐藏 </label>
            </div>
          </td>
        </tr>
        <tr>
          <td class="nametd">方向角（heading）</td>
          <td>
            <input id="model_heading" type="range" min="0" max="360" step="0.01" value="0" title="方向heading" />
          </td>
        </tr>
        <tr>
          <td class="nametd">俯仰角（pitch）</td>
          <td>
            <input id="model_pitch" type="range" min="-180" max="180" step="0.01" value="40" title="仰角pitch" />
          </td>
        </tr>
        <tr>
          <td class="nametd">左右角（roll）</td>
          <td>
            <input id="model_roll" type="range" min="-180" max="180" step="0.01" value="0" title="左右roll" />
          </td>
        </tr>

        <tr>
          <td class="nametd">夹角(半场角)</td>
          <td>
            <input id="model_angle1" type="range" min="0.1" max="89.9" step="0.01" value="5" />
          </td>
        </tr>
        <tr>
          <td class="nametd">长度（米）</td>
          <td>
            <input id="model_length" type="number" class="form-control" min="1" max="99999999999" step="1.0" value="700000" title="半径" />
          </td>
        </tr>
        <tr>
          <td class="nametd">顶盖</td>
          <td>
            <div class="checkbox checkbox-primary checkbox-inline">
              <input id="chkShowTop" class="styled" type="checkbox" checked />
              <label for="chkShowTop"> 是否显示 </label>
            </div>
          </td>
        </tr>
      </table>
    </div>

    <script src="./js/common.js"></script>
    <script type="text/javascript">
      'use script' //开发环境建议开启严格模式

      var map

      function initMap(options) {
        //合并属性参数，可覆盖config.json中的对应配置
        var mapOptions = mars3d.Util.merge(options, {
          scene: {
            center: {
              y: 23.775606,
              x: 116.715649,
              z: 1868684.2,
              heading: 354.9,
              pitch: -65.3,
              roll: 0,
            },
            cameraController: {
              constrainedAxis: false, //解除在南北极区域鼠标操作限制
            },
          },
        })

        //创建三维地球场景
        map = new mars3d.Map('mars3dContainer', mapOptions)

        //移除2.5D视图
        var arr = $('.cesium-sceneModePicker-wrapper').children()
        if (arr.length > 3) {
          arr[3].remove()
        }

        //创建矢量数据图层
        var graphicLayer = new mars3d.layer.GraphicLayer()
        map.addLayer(graphicLayer)

        //加个模型
        var graphic = new mars3d.graphic.ModelEntity({
          name: '地面站模型',
          position: [117.170264, 31.840312, 258],
          style: {
            url: 'http://data.marsgis.cn/gltf/mars/leida.glb',
            scale: 1,
            minimumPixelSize: 40,
            clampToGround: true,
          },
        })
        graphicLayer.addGraphic(graphic)

        //参数
        var heading = Number($('#model_heading').val())
        var pitch = Number($('#model_pitch').val())
        var roll = Number($('#model_roll').val())
        var angle = Number($('#model_angle1').val())
        var length = Number($('#model_length').val())

        //圆锥体
        var conicSensor = new mars3d.graphic.ConicSensor({
          position: [117.170264, 31.840312, 363],
          style: {
            angle: angle,
            length: length,
            // length: new Cesium.CallbackProperty(function (time) {
            //   length += 100 //测试动态length
            //   return length
            // }, false),
            heading: heading,
            pitch: pitch,
            roll: roll,
            color: 'rgba(255,0,0,0.4)',
            outlineColor: 'rgba(255,255,255,0.9)',
          },
        })
        graphicLayer.addGraphic(conicSensor)

        //测试连接线
        let testLine = new mars3d.graphic.PolylineEntity({
          positions: new Cesium.CallbackProperty(function (time) {
            var localEnd = conicSensor.rayPosition
            if (!localEnd) {
              return []
            }
            return [conicSensor.position, localEnd]
          }, false),
          style: {
            arcType: Cesium.ArcType.NONE,
            material: mars3d.MaterialUtil.createMaterialProperty(mars3d.MaterialType.PolylineDash, {
              color: '#ff0000',
            }),
            width: 1,
          },
        })
        graphicLayer.addGraphic(testLine)

        //滑动条
        $('#model_heading').range({
          onChange: function (value, bfb) {
            conicSensor.heading = value
          },
        })
        $('#model_pitch').range({
          onChange: function (value, bfb) {
            conicSensor.pitch = value
          },
        })
        $('#model_roll').range({
          onChange: function (value, bfb) {
            conicSensor.roll = value
          },
        })

        $('#model_angle1').range({
          onChange: function (value, bfb) {
            conicSensor.angle = value
          },
        })

        $('#model_length').change(function () {
          conicSensor.length = Number($(this).val())
        })

        $('#chkShowTop').change(function () {
          var val = $(this).is(':checked')
          conicSensor.topShow = val
        })
        $('#chkShow').change(function () {
          var val = $(this).is(':checked')
          conicSensor.show = val
          testLine.show = val
        })
      }
    </script>
  </body>
</html>
